#pragma once

#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unistd.h>
#include <functional>

using namespace std ;

typedef std::function<void()> func;

std::vector<func> callbacks; //callback为回调的意思
std::unordered_map<int,std::string> desc; //描述？？

void task1()
{
    cout<<"模拟任务-1 :"<< getpid() << endl;
}

void task2()
{
    cout<<"模拟任务-2 :"<< getpid() << endl;
}

void task3()
{
    cout<<"模拟任务-3 :"<< getpid() << endl;
}

void task4()
{
    cout<<"模拟任务-4 :"<< getpid() << endl;
}


//整个是在模拟加载任务

void load()
{

    desc.insert(make_pair(callbacks.size(),"模拟任务-1 "));
    callbacks.push_back(task1);

    desc.insert(make_pair(callbacks.size(),"模拟任务-2 "));
    callbacks.push_back(task2);

    desc.insert(make_pair(callbacks.size(),"模拟任务-3 "));
    callbacks.push_back(task3);

    desc.insert(make_pair(callbacks.size(),"模拟任务-4 "));
    callbacks.push_back(task4);

}


void showHandler()
{
    for(const auto &iter : desc)
    {
        cout << iter.first << "\t" << iter.second << endl ;
    }
}

int handlerSize()
{
    return callbacks.size();
}